package edu.nf.project.webs.accountsAndPermissions;

import edu.nf.project.entitys.dto.accountsAndPermissions.MineInfoDTO;
import edu.nf.project.services.accountsAndPermissions.MineInfoDTOService;
import edu.nf.project.services.exception.derivedAnomalies.CustomerOrderException;
import edu.nf.project.services.response.BaseController;
import edu.nf.project.services.response.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author gjh
 * @Date 2025/6/5
 * @Description:
 */
@RestController
@RequestMapping("/api/mineDTO")
public class MineInfoDTOController extends BaseController {
    @Autowired
    private MineInfoDTOService mineInfoDTOService;

    @GetMapping("/info")
    public ResultVO<MineInfoDTO> getMineInfoDTO(@RequestParam("t_id") String t_id) {
        try{
               MineInfoDTO info = mineInfoDTOService.selectMineInfoDTO(t_id);
            System.out.println(info);
            if (info == null) {
                throw new CustomerOrderException(30001, "用户未注册");
            }
            return success(info);
        }catch (Exception e) {
            if (e instanceof CustomerOrderException) {
                throw e;
            }
            System.out.println(e);
            throw new CustomerOrderException(30000, "系统错误，请稍后重试");
        }
    }
}
